* ======================================
* ----------- Import turnout -----------
* ======================================


* 2015 election
* =============

	use "$dta_raw\dta5\STEMMEBERETTIGEDE_2015.dta", clear
	rename w19 idPers
	gen zz=1 
	egen sum_zz = sum(zz), by(kommnr)
	gen vote = .
	replace vote = 0 if stemt_2015 == ""
	replace vote = 1 if stemt_2015 == "X"
	replace vote = . if sum_zz == 2186149  	// without mun. and voting records
	replace vote = . if sum_zz < 1000  		// election survey only
	gen year = 2015
	keep idPers vote year
	tempfile vote2015
	save `vote2015'


* 2019 election
* =============

	use "$dta_raw\dta5\STEMMEBERETTIGEDE_2019.dta", clear
	rename w19 idPers
	gen vote = .
	replace vote = 0 if stemt == ""
	replace vote = 1 if stemt == "x"
	gen year = 2019
	keep idPers vote year
	
	tempfile vote2019
	save `vote2019'
	
	
* Append in long format
* =====================

	clear
	append using `vote2015'
	append using `vote2019'
	save "$dta\ImportTurnout.dta", replace